Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: check at runtime that all tests call expect #706

Merged
merged 1 commit into from
Oct 9, 2023

Conversation

sheerlox
Copy link
Collaborator

Description

Make sure every test calls expect(), even asynchronously.

(method) jest.Expect.hasAssertions(): void
Verifies that at least one assertion is called during a test. This is often useful when testing asynchronous code, in order to make sure that assertions in a callback actually got called.

Related Issue

N/A

Motivation and Context

Since we sometimes use expect() in the onTick callback, tests could pass if the callback is never called, resulting in bugs not being detected by our test suites.

How Has This Been Tested?

Temporarily removed the cloc.tick() call on an asynchronous test, successfully failing the test where it was previously succeeding.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • If my change introduces a breaking change, I have added a ! after the type/scope in the title (see the Conventional Commits standard).

@sheerlox sheerlox requested a review from intcreator September 30, 2023 15:19
@sheerlox sheerlox self-assigned this Sep 30, 2023
@sheerlox sheerlox added the type:test Adding missing tests or correcting existing tests label Sep 30, 2023
@sheerlox sheerlox merged commit cc4e62f into kelektiv:main Oct 9, 2023
10 checks passed
@sheerlox sheerlox deleted the test/runtime-assertions-check branch October 9, 2023 12:40
ncb000gt pushed a commit that referenced this pull request Oct 9, 2023
## [3.1.0](v3.0.0...v3.1.0) (2023-10-09)

### ✨ Features

* improve context, onTick & onComplete typings ([#705](#705)) ([82c78d7](82c78d7))

### 🚨 Tests

* check at runtime that all tests call expect ([#706](#706)) [skip ci] ([cc4e62f](cc4e62f))

### ♻️ Chores

* **deps:** update semantic-release related packages ([#709](#709)) [skip ci] ([b94a48a](b94a48a))
* reflect repository label changes ([#708](#708)) ([85c9e18](85c9e18))
@ncb000gt
Copy link
Member

ncb000gt commented Oct 9, 2023

🎉 This PR is included in version 3.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@sheerlox sheerlox removed their assignment Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released type:test Adding missing tests or correcting existing tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants